<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<table id="picklist_list" class="easyui-datagrid"
       fit="true" border="false"
       singleSelect="true" fitColumns="true" pagination="true" toolbar="#toolbar_picklist"
       idField="picklistId" url="../picklist/loadList.action">
    <thead>
    <tr>
        <th field="picklistname" width="60">字典名称</th>
        <th field="picklistkey" width="60">字典KEY</th>
    </tr>
    </thead>
</table>
<div id="toolbar_picklist">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-view',plain:true" onclick="picklist_view()" />
    <shiro:hasPermission name="picklist_add">
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="loadWin('添加字典','../../shiro/picklist/showedit.action?picklist_id=0')" />
    </shiro:hasPermission>
    <shiro:hasPermission name="picklist_edit">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="picklist_showedit()" />
    </shiro:hasPermission>
    <shiro:hasPermission name="picklist_delete">
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="picklist_remove()"/>
    </shiro:hasPermission>
</div>
<script>
    function picklist_showedit() {
        //获取选中的列
        var selected = $("#picklist_list").datagrid("getSelected");
        if(selected==null){
            alert('请选择行！');
        }else{
            //进行编辑操作
            loadWin('添加字典','../../shiro/picklist/showedit.action?picklist_id='+selected.picklistId);
        }
    }
    function picklist_remove() {
        var selected = $("#picklist_list").datagrid("getSelected");
        if(selected==null){
            alert('请选择行！');
        }else{
            $.messager.confirm('确认','您确认想要删除记录吗？',function(r){
                if (r){
                    $.post('../../shiro/picklist/remove.action',{picklist_id:selected.picklistId},function (res) {
                        $("#picklist_list").datagrid("reload");
                    });
                }
            });
        }
    }
    /**
     * 查看字典
     */
    function picklist_view() {
        var selected = $("#picklist_list").datagrid("getSelected");
        if(selected==null){
            alert('请选择行！');
        }else{
            //进行编辑操作
            loadWin('查看字典','../../shiro/picklist/view.action?picklist_id='+selected.picklistId);
        }
    }
</script>
